package icu.bughub.app.app.model

import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory

object NetWork {

    // 文档地址  https://docs.apipost.cn/preview/1a28e17fa3c8f473/16838456ae6dc5c7

    // mock数据的请求url
    private const val BASE_URL =
        "https://mock.apipost.cn/app/mock/project/ced69cf2-9206-4a42-895e-dd7442a888df/"

    private val retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(
            MoshiConverterFactory.create(
                Moshi.Builder().add(
                    KotlinJsonAdapterFactory()
                ).build()
            )
        ).build()


    fun <T> createService(service: Class<T>): T {
        return retrofit.create(service)
    }
}